﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LowLevelGraphics.Filter
{
    //imadjust: matlab image processing toolbox
    /// <summary>
    /// J = imadjust(I,[low_in high_in],[low_out high_out],gamma) 
    /// maps the values in intensity image I to new values in J such that values 
    /// between low_in and high_in map to values between low_out and high_out. 
    /// Values below low_in and above high_in are clipped; 
    /// that is, values below low_in map to low_out, and those above high_in map to high_out. 
    /// You can use an empty matrix ([]) for [low_in high_in] or for [low_out high_out] to specify the default of [0 1]. 
    /// 
    ///gamma specifies the shape of the curve describing the relationship between the values in I and J.
    ///If gamma is less than 1, the mapping is weighted toward higher (brighter) output values.
    ///If gamma is greater than 1, the mapping is weighted toward lower (darker) output values.
    ///If you omit the argument, gamma defaults to 1 (linear mapping).
    ///
    ///newmap = imadjust(map,[low_in; high_in],[low_out;high_out],gamma) transforms the colormap 
    ///associated with an indexed image. If low_in, high_in, low_out, high_out, and gamma are scalars, 
    ///then the same mapping applies to red, green and blue components. 
    ///Unique mappings for each color component are possible when
    ///
    ///    * low_in and high_in are both 1-by-3 vectors
    ///
    ///      low_out and high_out are both 1-by-3 vectors, or gamma is a 1-by-3 vector.
    ///
    ///The rescaled colormap, newmap, is the same size as map.
    ///
    ///RGB2 = imadjust(RGB1,...) performs the adjustment on each image plane (red, green, and blue) of the RGB image RGB1.
    ///As with the colormap adjustment, you can apply unique mappings to each plane.
    ///
    ///Note   <!-- If high_out < low_out, the output image is reversed, as in a photographic negative. --> 
    ///
    ///The function stretchlim can be used with imadjust to apply an automatically computed contrast stretch.
    ///</summary>
    public class ImageAdjust : BaseImageFilter
    {
        public ImageAdjust()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ImageAdjust"/> class.
        /// </summary>
        /// <param name="_imageAdjust">The _image adjust.</param>
        internal ImageAdjust(ImageAdjust _imageAdjust)
        {
        }

        /// <summary>
        /// Execute this Filter
        /// A Debug Statement is written if a concrete Filter is called
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            return base.Execute(_bitmap);
        }

        /// <summary>
        /// This is used to clone a filter, each filter must implement it's own clone functionality
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new ImageAdjust(this);
        }
    }
}
